import {
    getLeadInClientLessees,
    getLeadInErrorInfos
} from "@/views/wy-lessor/landlord/api/lessor";
/*import {getLeadInClientProvider} from '@/views/client-manage/api/clientprovider'*/

export default {
    name: "leading-in-table",
    data() {
        return {
            // hxf-0806-上传组件使用-----开始--------------
            fileSize: 50,
            tableData: [],
            tableWarnData: [],
            activeName: "first"
        };
    },
    props: {
        tableDataInfo: {
            type: Array,
            default: () => {}
        },
        clientType: {
            type: String
        }
    },
    mounted() {
        this.getData();
    },
    methods: {
        getData() {
            console.log(this.tableDataInfo, "table-this.tableDataInfo");
            if (this.clientType === "provider") {
                if (
                    this.tableDataInfo != null &&
                    this.tableDataInfo.clientIds != null &&
                    this.tableDataInfo.clientIds.length != 0
                ) {
                    getLeadInClientProvider({
                        clientIds: this.tableDataInfo.clientIds
                    }).then(resp => {
                        console.log(resp, "table.resp");
                        this.tableData = resp.data.data;
                    });
                }
            } else {
                if (
                    this.tableDataInfo != null &&
                    this.tableDataInfo.clientIds != null &&
                    this.tableDataInfo.clientIds.length != 0
                ) {
                    getLeadInClientLessees({
                        clientIds: this.tableDataInfo.clientIds
                    }).then(resp => {
                        console.log(resp, "table.resp");
                        this.tableData = resp.data.data;
                    });
                }
            }
            if (
                this.tableDataInfo != null &&
                this.tableDataInfo.leadInErrorInfoIds != null &&
                this.tableDataInfo.leadInErrorInfoIds.length != 0
            ) {
                getLeadInErrorInfos({
                    leadInErrorInfoIds: this.tableDataInfo.leadInErrorInfoIds
                }).then(resp => {
                    console.log(resp, "tableWarnData.resp");
                    this.tableWarnData = resp.data.data;
                });
            }
        },
        exportExcleError() {
            let name =
                this.clientType == "provider"
                    ? "供应商导入异常数据"
                    : "承租方导入异常数据";

            let url = "/api/leadinerrorinfo/leadinerrorinfo_recording_download";
            this.publicExport(name, url, {
                leadInErrorInfoIds: this.tableDataInfo.leadInErrorInfoIds
            });
        }
    }
};
